package com.jawmask.android.discover.utils;

import java.util.WeakHashMap;

import android.graphics.Bitmap;

public final class ImageCacheUtils {

	private static ImageCacheUtils imageCacheUtils;
	private WeakHashMap<String, Bitmap> imageCaches;

	private ImageCacheUtils() {
		imageCaches = new WeakHashMap<String, Bitmap>();
	}

	public static ImageCacheUtils getInstance() {
		if (imageCacheUtils == null)
			imageCacheUtils = new ImageCacheUtils();
		return imageCacheUtils;
	}

	public Bitmap addImage(final String imagePath, final Bitmap bitmap) {
		return imageCaches.put(imagePath, bitmap);
	}

	public Bitmap getImage(final String imagePath) {
		return imageCaches.get(imagePath);
	}

	public void clearAll() {
		imageCaches.clear();
	}
}
